package com.dingpeikeji.quickdeer.modules.rentproduct.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dingpeikeji.quickdeer.core.common.persistence.Page;
import com.dingpeikeji.quickdeer.core.common.service.CrudService;
import com.dingpeikeji.quickdeer.core.modules.sys.utils.UserUtils;
import com.dingpeikeji.quickdeer.modules.rentproduct.dao.TRentgroupAuditDao;
import com.dingpeikeji.quickdeer.modules.rentproduct.dao.TRentgroupDao;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.TRentgroup;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.TRentgroupAudit;

/**
 * 整车发布审核Service
 * @author dp
 * @version 2017-01-03
 */
@Service
@Transactional(readOnly = true)
public class TRentgroupAuditService extends CrudService<TRentgroupAuditDao, TRentgroupAudit> {

	@Autowired
	private TRentgroupDao RentgroupDao;
	
	public TRentgroupAudit get(String id) {
		return super.get(id);
	}
	
	public List<TRentgroupAudit> findList(TRentgroupAudit tRentgroupAudit) {
		return super.findList(tRentgroupAudit);
	}
	
	public Page<TRentgroupAudit> findPage(Page<TRentgroupAudit> page, TRentgroupAudit tRentgroupAudit) {
		return super.findPage(page, tRentgroupAudit);
	}
	
	@Transactional(readOnly = false)
	public void save(TRentgroupAudit tRentgroupAudit) {
		TRentgroup rentgroup = RentgroupDao.get(tRentgroupAudit.getRentgroup().getRentgrpid());
		rentgroup.setAuditstatus(tRentgroupAudit.getAuditopn());
		RentgroupDao.auditRentgroup(rentgroup);
			
		tRentgroupAudit.setOperaterid(UserUtils.getUser().getId());
		tRentgroupAudit.setOperatedate(new Date());
		dao.insert(tRentgroupAudit);
	}
	
	@Transactional(readOnly = false)
	public void delete(TRentgroupAudit tRentgroupAudit) {
		super.delete(tRentgroupAudit);
	}
	
}